package cn.com.cennavi.test;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.io.WKTReader;

import cn.com.cennavi.bean.DifPointTotalMapInfo;
import cn.com.cennavi.bean.HighPrecisionCombineDirTraffic;
/**
 * 
 * @author Thinkpad
 *
 */
public class TimeUtil {
	static SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

	public static void main(String[] args) throws IOException, ParseException, com.vividsolutions.jts.io.ParseException {
		// TODO Auto-generated method stubtraffic-1462083260000.lane
		HashMap<String, String> dataMap2 = new HashMap<String, String>();
		BufferedReader br = new BufferedReader(new FileReader(new File("D:\\data\\621标准答案匹配出来的路况.txt")));
		String line = "";
		HashSet<String> dataSet = new HashSet<>();
		HashMap<String, String> dataMap = new HashMap<>();
		while ((line = br.readLine()) != null) {
			String[] lineArr = line.split(",");
			dataMap.put(lineArr[1], line);
		}
		BufferedReader br1 = new BufferedReader(new FileReader(new File("D:\\data\\DifPointTotalMapInfo.csv")));
		String line1 = "";
		HashMap<String, String> dataMap1 = new HashMap<>();
		while ((line1 = br1.readLine()) != null) {
			String[] lineArr = line1.split(",");
			dataMap1.put(lineArr[7] + "|" + lineArr[8],getGeo(lineArr));
		}
		for (Map.Entry<String, String> entry : dataMap.entrySet()) {
			String key = entry.getKey();
			String value = dataMap1.get(key).replace("(", "").replace(")", "").replace("POLYGON", "").trim();
			dataMap2.put(key,  value);
		}
		for (Map.Entry<String, String> e : dataMap2.entrySet()) {
			String []val=e.getValue().split(",");
			String key=e.getKey();
			for(String sss:val){
				System.out.println(sss+" "+key);
				
			}
		}
	}
	private static String getGeo(String[] lineArr) throws ParseException {
		// TODO Auto-generated method stub
//		int length = lineArr.length;
		String outLine = "";
		for (int i = 16; i < lineArr.length; i++) {
			outLine += lineArr[i];
			if (i != lineArr.length - 1) {
				outLine += ",";
			}
		}
//		Geometry g1 = new WKTReader().read(outLine);
		return outLine;
	}

}
